package com.hangzhou.xyj.utils;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.util.DisplayMetrics;
import android.view.View;

import com.hangzhou.xyj.ui.widget.views.MyTextView;

/**
 * Created by XieMing on 2016/3/19.
 */
public class Utils {

    public static void showAndDismissView(View view, boolean isShow) {
        if (view != null) {
            int visibility = isShow ? View.VISIBLE : View.INVISIBLE;
            if (view.getVisibility() != visibility) {
                view.bringToFront();
                view.setVisibility(visibility);
            }
        }
    }

    public static void setTextColor(MyTextView view, boolean isSelected) {
        if (view != null) {
            view.setTextColor(isSelected ? Color.parseColor("#440303") : Color.WHITE);
        }
    }

    public static int getScreenWidth(Context context) {
        Resources resources = context.getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        return dm.widthPixels;
    }
}
